package com.mls.fivedistrict.server;

import com.mls.fivedistrict.enums.CaptchaTypeEnum;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by chenxiuxiang on 2018/3/23.
 */
@Service
public class SendMessageUtil {

    @Resource(name = "commonService")
    private CommonService commonService;

    @Async
    public void sendMessage(String phone, String code) {
        try {
            Thread.sleep(60 * 1000);
            commonService.getCaptchaByCode(phone, CaptchaTypeEnum.SUBSCRIBESUCCESS.getType(), code);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }

    @Async
    public void sendMessageByType(String phone, String type) {
        commonService.getCaptcha(phone, type);
    }
}
